var a = require("../../requests/request.js"), e = getApp();

Page({
    data: {
        currentTab: 0,
        swiperTab: 0,
        option: null,
        winWidth: 0,
        winHeight: 0,
        hothidden: !1,
        exphidden: !1,
        cheaphidden: !1,
        bestSellData: null,
        expensiveData: null,
        cheapestData: null,
        bestPage: 1,
        expensivePage: 1,
        cheapestPage: 1,
        pic: "http://image.bitautoimg.com/autoalbum/V2.1/images/150-100.gif"
    },
    onLoad: function(a) {
        var e = this;
        if (wx.getSystemInfo({
            success: function(a) {
                e.setData({
                    winWidth: a.windowWidth,
                    winHeight: a.windowHeight
                });
            }
        }), "" != a) {
            var t = "&";
            for (var n in a) t += n + "=" + a[n] + "&";
            e.setData({
                params: t
            });
        }
    },
    onReady: function() {
        this.loadTiaoJianData();
    },
    onPullDownRefresh: function() {
        this.loadTiaoJianData(), wx.stopPullDownRefresh();
    },
    loadTiaoJianData: function() {
        var e = this, t = e.data.params;
        console.log(t), a.getCarSelect(t + "s=4", function(a) {
            e.setData({
                bestSellData: a.Data.List,
                bestPage: 2
            });
        }), a.getCarSelect(t + "s=3", function(a) {
            console.log(a), e.setData({
                expensiveData: a.Data.List,
                expensivePage: 2
            });
        }), a.getCarSelect(t + "s=2", function(a) {
            e.setData({
                cheapestData: a.Data.List,
                cheapestPage: 2
            });
        });
    },
    clickCar: function(a) {
        var e = a.currentTarget.dataset.id, t = a.currentTarget.dataset.name;
        wx.navigateTo({
            url: "../summary/summary?id=" + e + "&name=" + t
        });
    },
    swiperchange: function(a) {
        this.setData({
            currentTab: a.detail.current
        });
    },
    swichNav: function(a) {
        var e = this;
        if (this.data.currentTab === a.currentTarget.dataset.current) return !1;
        e.setData({
            currentTab: a.currentTarget.dataset.current,
            swiperTab: a.currentTarget.dataset.current
        });
    },
    getBestSellData: function() {
        var e = this;
        if (e.data.hothidden) e.setData({
            hothidden: !1
        }); else {
            var t = e.data.params;
            e.setData({
                hothidden: !0
            }), a.getCarSelect(t + "page=" + e.data.bestPage + "&s=4", function(a) {
                console.log(a);
                var t = [], n = a.Data.List;
                t = e.data.bestSellData.concat(n), e.setData({
                    bestSellData: t,
                    bestPage: e.data.bestPage + 1,
                    hothidden: !1
                });
            });
        }
    },
    getExpensiveData: function() {
        var e = this;
        if (e.data.exphidden) e.setData({
            exphidden: !1
        }); else {
            e.setData({
                exphidden: !0
            });
            var t = e.data.params;
            a.getCarSelect(t + "page=" + e.data.expensivePage + "&s=3", function(a) {
                var t = [], n = a.Data.List;
                t = e.data.expensiveData.concat(n), console.log(a), e.setData({
                    expensiveData: t,
                    expensivePage: e.data.expensivePage + 1,
                    exphidden: !1
                });
            });
        }
    },
    getCheapest: function() {
        var e = this;
        if (e.data.cheaphidden) e.setData({
            cheaphidden: !1
        }); else {
            e.setData({
                cheaphidden: !0
            });
            var t = e.data.params;
            a.getCarSelect(t + "page=" + e.data.cheapestPage + "&s=2", function(a) {
                var t = [], n = a.Data.List;
                t = e.data.cheapestData.concat(n), e.setData({
                    cheapestData: t,
                    cheapestPage: e.data.cheapestPage + 1,
                    cheaphidden: !1
                });
            });
        }
    },
    returnBtn: function() {
        e.gotoIndex();
    }
});